<include file="Public/header"/>
<div class="layui-tab">
	<ul class="layui-tab-title">
		<li class="layui-this" data-url="<{:U('User/editUser',array('uid'=>$_GET['uid']))}>" onclick="load_url(this)">商户信息</li>
		<li class="" data-url="<{:U('User/userWithdrawal',array('uid'=>$_GET['uid']))}>" onclick="load_url(this)">提现</li>
		<li class="" data-url="<{:U('User/editUserProduct',array('uid'=>$_GET['uid']))}>" onclick="load_url(this)">通道</li>
		<li class="" data-url="<{:U('User/userRateEdit',array('uid'=>$_GET['uid']))}>" onclick="load_url(this)">费率</li>
	</ul>
	<div class="layui-tab-content">
		<div class="layui-tab-item layui-show">
			<form class="layui-form" action="" id="profile">
				<input type="hidden" name="userid" value="<{$u.id}>">
				<input type="hidden" name="salt" value="<{$u.salt}>">
				<input type="hidden" name="groupid" value="<{$u.groupid}>">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">用户名：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[username]" lay-verify="required" autocomplete="off" value="<{$u.username}>" placeholder="用户名" class="layui-input" <if condition="$u.id gt 0">disabled="disabled"</if>
							>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">姓名：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[realname]" lay-verify="required" autocomplete="off" value="<{$u.realname}>" placeholder="姓名"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">登录密码：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[password]" autocomplete="off" value="" placeholder="修改登录密码" class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">支付密码：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[paypassword]" lay-verify="" autocomplete="off" value="" placeholder="修改支付密码" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">性别：</label>
						<div class="layui-input-inline">
							<select name="u[sex]" lay-search="">
								<option <if condition="$u['sex'] eq 0">selected</if> value="0">女</option>
								<option <if condition="$u['sex'] eq 1">selected</if> value="1">男</option>
							</select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">身份证号：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[sfznumber]" lay-verify="required" autocomplete="off" value="<{$u.sfznumber}>" placeholder="身份证号" class="layui-input">
						</div>
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">出生日期：</label>
						<div class="layui-input-inline">
							<input class="layui-input"  placeholder="出生日期" id="birthday" value="<{$u[birthday]|date="Y-m-d",###}>">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">手机号码：</label>
						<div class="layui-input-inline">
							<input class="layui-input" name="u[mobile]" placeholder="" value="<{$u[mobile]}>">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">联系QQ：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[qq]" autocomplete="off" value="<{$u.qq}>" placeholder="联系QQ" class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">Email：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[email]" lay-verify="required" autocomplete="off" value="<{$u.email}>" placeholder="Email" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">用户级别：</label>
						<div class="layui-input-inline">
							<select name="u[groupid]" lay-verify="required" lay-search="">
								<option value=""></option>
								<foreach name="groupId" item="v" key="k">
									<option <if condition="$u['groupid'] eq $k">selected</if>
									value="<{$k}>"><{$v}></option>
								</foreach>
							</select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">联系地址：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[address]" lay-verify="required" autocomplete="off" value="<{$u.address}>" placeholder="联系地址" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">所属代理商：</label>
						<div class="layui-input-inline">
							<select name="u[parentid]" lay-verify="required" lay-search="">
								<option value="1">无代理商</option>
								<foreach name="group" item="v" key="k">
									<option <if condition="$u['parentid'] eq $v['id']">selected</if>
									value="<{$v['id']}>"><{$v['realname']}></option>
								</foreach>
							</select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">结算方式：</label>
						<div class="layui-input-inline">
							<select name="u[withdrawtype]" lay-verify="required" lay-search="">
								<option value=""></option>
								<option value="1" <if condition="$u['withdrawtype'] eq 1">selected</if>>仅子商户可提</option>
								<option value="2" <if condition="$u['withdrawtype'] eq 2">selected</if>>仅代理商户可提</option>
								<option value="3" <if condition="$u['withdrawtype'] eq 3">selected</if>>子商户、代理商户均可提</option>
							</select>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-form-item">
						<label class="layui-form-label">谷歌密钥：</label>
						<div class="layui-input-inline">
							<input type="text" name="u[google_secret]" autocomplete="off" value="<{$u.google_secret}>" placeholder="谷歌密钥"
								   class="layui-input" id="md5key">
						</div>
						<button type="button" class="btn btn-primary" onclick="changeKey()">生成密钥</button>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label"></label>
						<button  class="btn btn-primary" lay-submit="submit" lay-filter="save">提交保存</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<include file="Public/footer"/>
<script>
layui.use(['layer', 'form','laydate'], function(){
  var form = layui.form
  ,laydate = layui.laydate
  ,layer = layui.layer;

    //常规用法
    laydate.render({
        elem: '#birthday'
    });
  //监听提交
  form.on('submit(save)', function(data){
    $.ajax({
		url:"<{:U('User/saveUser')}>",
		type:"post",
		data:$('#profile').serialize(),
		success:function(res){
			if(res.status){
				layer.alert("编辑成功", {icon: 6},function () {
					parent.location.reload();
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				});
			}else{
                layer.alert("操作失败:" + res.msg, {icon: 5},function (index) {
                    layer.close(index)
                });
			}
		}
	});
    return false;
  });
});

function load_url(url){
    var url = $(url).data('url');
    location.href = url;
}

//监听切换密钥
function changeKey(){
    $.ajax({
        url:"<{:U('User/makeSecret')}>",
        type:"GET",
        success:function(str){
            $('#md5key').val(str);
        }
    });
    return false;
}
</script>
</body>
</html>
